﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Web.Mvc;
using Vit.Common.Extensions;
using Vit.Web.Data;
using Vit.Web.Extensions;
using Vit.Web.Mvc.Results;

namespace Vit.Web.Mvc
{
    public class ListViewUserControl<TEntity, TFilterEntity> : ViewUserControl<IEnumerable<TEntity>>
        where TEntity : class, new()
        where TFilterEntity : class, new()
    {
        public TFilterEntity FilterEntity
        {
            get
            {
                return ViewData["FilterObject"] as TFilterEntity;
            }
        }

        public PagingInfo Paging
        {
            get
            {
                if (this.Model is PageOfList<TEntity>)
                {
                    return ((PageOfList<TEntity>)this.Model).PagingInfo;
                }
                return null;
            }
        }

        public Type FilterType
        {
            get
            {
                return typeof(TFilterEntity);
            }
        }

        public Type ModelType
        {
            get
            {
                return typeof(TEntity);
            }
        }
    }
}
